﻿using System;
using System.Windows.Controls;
using System.Windows.Threading;
using WapChargingSDK;

namespace NapThe
{
    public partial class GamePageNapThe : UserControl, IGamePage
    {
        Grid MainLayoutRoot;
        NapXu napxu;
        DispatcherTimer timer;
        public int second = 0;
        public bool isShown = false;
        public bool isHiden = true;
        public static bool isNapTien = false;
        public static string tien;
        public GamePageNapThe(Grid MainLayoutRoot, NapXu napxu)
        {
            InitializeComponent();
            this.MainLayoutRoot = MainLayoutRoot;
            this.MainLayoutRoot.Children.Add(this);
            this.napxu = napxu;
            pagenapthe.Begin();
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(500);
            timer.Tick += OnTimerTick;
            timer.Start();
        }
        public void hieuung() { this.pagenapthe.Begin(); }
        private void OnTimerTick(object sender, EventArgs e)
        {
            if (isNapTien)
            {
               
                if (!napxu.isVisible()
                    && second <= 6 && second >= 0 && !isShown)
                {
                    //textBlock1b.Visibility = System.Windows.Visibility.Visible;
                    textBlock2b.Visibility = System.Windows.Visibility.Visible;
                    button2.Visibility = System.Windows.Visibility.Visible;
                    //MessageBox.Show("dsads");
                    textBlock2b.Text = KhongDuXu.preAccount
                                + " ngọc.";

                    isShown = true;

                    return;
                }
            }
         
                if (isNapTien && !napxu.isVisible())
                {
                    second++;

                    //}

                    if (second > 6 && isShown)
                    {

                       // textBlock1b.Visibility = System.Windows.Visibility.Collapsed;
                        textBlock2b.Visibility = System.Windows.Visibility.Collapsed;
                        button2.Visibility = System.Windows.Visibility.Collapsed;

                        isNapTien = false;
                        isShown = false;
                        KhongDuXu.preAccount = "";
                        second = 0;
                        return;
                    }
                }
           
        }
       // protected override onn(NavigationEventArgs e) {pagenapthe.begin(); }

        public void setTextBlock5(string text)
        {
            textBlock5.Text = text;
            tien = text;
            textBlock5.Visibility = System.Windows.Visibility.Collapsed;
        }
    }
}
